clear all
set more off, perm
set maxvar 120000
set varabbrev off
* ---------------------------------------------- *
global dir 	"`1'"
global Data 	$dir/Data
global Tables 	$dir/Tables
global Figures 	$dir/Figures
global Work 	$dir/Work
global Temp 	$dir/Temp
global Pseudo	$dir/Work/Temp
* ---------------------------------------------- *
local i=1
foreach EBR in qped qslo {
use $Work/portfolio_BOOK_`EBR', clear	
tsset portf datem
eststo clear
gen cumQ=.

* New returns; add EBRs as a control
eststo clear

replace cumQ=cumQRetMo1	
eststo Mo1_`x': quietly: ivreg2 cumNRetMo1 cumQ if portf==6, bw(1 ) robust small

replace cumQ=cumQRetQr1	
eststo Qr1_`x': quietly: ivreg2 cumNRetQr1 cumQ if portf==6, bw(4 ) robust small

replace cumQ=cumQRetYr1	
eststo Yr1_`x': quietly: ivreg2 cumNRetYr1 cumQ if portf==6, bw(13)robust small

replace cumQ=cumQRetYr3	
eststo Yr3_`x': quietly: ivreg2 cumNRetYr3 cumQ if portf==6, bw(37)robust small

replace cumQ=cumQRetYr5	
eststo Yr5_`x': quietly: ivreg2 cumNRetYr5 cumQ if portf==6, bw(61)robust small

display "`i'"
if `i'==1 {
esttab Mo1_* Qr1_* Yr1_* Yr3_* Yr5_* using $Tables/AppendixB3_June.csv,  nonotes compress b(4) se(4) star(c 0.10 b 0.05 a 0.01) nolabel nogap ar2 title(`PORTF') replace
}
if `i'>1 {
esttab Mo1_* Qr1_* Yr1_* Yr3_* Yr5_* using $Tables/AppendixB3_June.csv,  nonotes compress b(4) se(4) star(c 0.10 b 0.05 a 0.01) nolabel nogap ar2 title(`PORTF') append
}
local i=`i'+1 
}
